﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using PMServiceDesk.DataType;
using PMServiceDesk.Utils.ManejoDatos;

namespace PMServiceDesk.DataAccess
{
    public class LineaBaseImportarData
    {
        public List<LineaBaseImportarType> CargarLista(string path)
        {
            List<LineaBaseImportarType> l = new List<LineaBaseImportarType>();

            using (DataUtil d = new DataUtil())
                using (IDataReader r = d.ExecuteReaderExcel(path))
                {
                    LineaBaseImportarType o = null;

                    while (r.Read())
                    {
                        o = new LineaBaseImportarType();

                        o.CodigoCuenta = r.GetValue(0).ToString().Trim();
                        o.Tarea = r.GetValue(1).ToString().Trim();
                        o.Tipo = r.GetValue(2).ToString().Trim();
                        o.Responsable = r.GetValue(3).ToString().Trim();
                        o.FechaInicio = ConvertFormat.Date_To_Char(r.GetValue(4));
                        o.FechaFin = ConvertFormat.Date_To_Char(r.GetValue(5));
                        o.RecursosFormat = r.GetValue(6).ToString().Trim();

                        l.Add(o);
                    }
                }

            return (
                        from registro in l
                        orderby registro.CodigoCuenta
                        select registro
                   ).ToList();
        }
    }
}
